#include "CfgData.h"
#include "../common/TKAssistorPathMgr.h"
#include "../common/HartGlbPure.h"

CCfgData::CCfgData()
{
	CTKAssistorPathMgr oPathMgr;
	m_strCfgFullPath = oPathMgr.GetAppPath();
	m_strCfgFullPath += LR"(\cfg.ini)";
}

CCfgData::~CCfgData()
{
}

std::string  CCfgData::GetIp()
{
	TCHAR buf[256] = { 0 };
	GetPrivateProfileString(
		L"NET",
		L"IP",
		L"192.168.2.253",
		buf,
		256,
		m_strCfgFullPath.c_str());

	std::wstring strBuf = buf;
	return std::move(WstringToString(strBuf));
}

void CCfgData::SetIP(std::wstring && acsIP)
{
	WritePrivateProfileString(
		L"NET",
		L"IP",
		std::move(acsIP).c_str(),
		m_strCfgFullPath.c_str());
}

std::wstring CCfgData::GetPort()
{
	TCHAR buf[256] = { 0 };
	GetPrivateProfileString(
		L"NET",
		L"PORT",
		L"502",
		buf,
		256,
		m_strCfgFullPath.c_str());

	return buf;
}

void CCfgData::SetPorts(std::wstring && aiPort)
{
	WritePrivateProfileString(
		L"NET",
		L"PORT",
		std::move(aiPort).c_str(),
		m_strCfgFullPath.c_str());
}
